package br.com.lajeslaboratorio.lajesweb.util;

import java.util.ResourceBundle;

import javax.faces.application.FacesMessage;
import javax.faces.application.FacesMessage.Severity;
import javax.faces.context.FacesContext;

public class MessageUtil {
	
    public static ResourceBundle getMessageBundle() {
    	return ResourceBundle.getBundle(FacesUtil.getFacesContext().getApplication().getMessageBundle());
    }
    
    public static void addMessage(FacesMessage facesMessage) {
    	FacesContext.getCurrentInstance().addMessage("redirectMessages", facesMessage);
    }

	public static void addNewMessage(Severity severity, String mainMessage, String secondMessage){
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, mainMessage, secondMessage));
	}
	
	public static void addInfoMessage(String msg){
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, msg, null));
	}
	
	public static void addWarnMessage(String msg){
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, msg, null));
	}
	
	public static void addErrorMessage(String msg){
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null));
		
	}
	
	public static void addFatalMessage(String msg){
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, msg, null));
	}
	
	public static FacesMessage getInfoFacesMessage(String msg){
		return new FacesMessage(FacesMessage.SEVERITY_INFO, msg, null);
	}
}
